#! /usr/bin/env python
""" NMDB database table formats

Copyright (c) 2011-2013 Christian T. Steigies <steigies@physik.uni-kiel.de>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

__author__ = "Christian T. Steigies <steigies@physik.uni-kiel.de>"
__license__ = "GPL License"


__all__ = ["sql_format", "sql_create", "sql_insert", "sql_select", "sql_print"]

## --------------------------------------------------------------------------

# NMDB format
# TODO create format and columns from list
sql_format = (
    "datetime timestamp, "
    "interval int, "
    "ucorr real, "
    "corr_e real, "
    "corr_p real, "
    "pressure real"
    )

sql_columns = (
    "datetime, "
    "interval, "
    "ucorr, "
    "corr_e, "
    "corr_p, "
    "pressure"
    )


sql_create = ("CREATE TABLE data (" + sql_format +")")

sql_insert = "INSERT INTO data (" + sql_columns + ") VALUES (?, ?, ?, ?, ?, ?)"

sql_select = "SELECT " + sql_columns + " FROM data"

sql_print = "%s %i %.2f %.2f %.2f %.2f"
            
## --------------------------------------------------------------------------
if __name__ == "__main__":
    print "This is the sqlite format helper module."

    print "sql_create:", sql_create
    print "sql_insert:", sql_insert
    print "sql_select:", sql_select
    print "sql_print:", sql_print
    
